package com.app.micaihu.bean.infor;

import android.text.TextUtils;

import com.app.utils.util.StringUtils;

import java.util.List;


/**
 * Created by Guo on 2016/7/13.
 * <p>
 * 用户的任务信息
 * <p>
 * <p>
 * 新增加五个字段:是否 可领取/已领取
 */
public class UserTask {

    private String level;// 军衔
    private String militaryExploit = "";// 军功
    private String militarPay;// 金币

    private String mobileBind;//是否绑定手机

    private String dayPay;//今日收获金币
    private String dayExploit;//今日收获军功
    private String dayPayMax;//今日最大收获的金币
    private String dayExploitMax;//今日最大收获的军功


    private String isLevelUp;//是否升级

    private String prevRankName;//上一个军衔名称
    private String rankName;//当前军衔名称
    private String nextRankName;//下一级军衔名称

    private String rankIcon;//当前军衔图标
    private String nextRankIcon;//下一集级军衔图标
    private String prevRankIcon;//上一个军衔图标


    private String militaryExploitDiff;//距下一级军衔需要的军功百分比
    private String militaryDiff;//距下一级军衔需要的军功


    private String firstLogin;//是否第一次登录
    private String inviteNum;//邀请
    private String wxAttion;//微信关注 去掉了
    private String signIn;//是否签到
    private String commentNum;//发表评论次数
    private String shareNum;//分享文章次数
    private String readNum;//阅读文章次数
    private String gameDownloadNum;//下载游戏次数
    private String isInvited;//是否填写邀请码  0 没有  1有

    //作战奖励 1.0.1
    private String rewardWx;//关注微信领取状态
    private String rewardMobile;//绑定手机领取状态
    private String rewardSignSeven;//签到7天领取
    private String rewardSignThirty;//签到30天领取
    private String rewardInviteTen;//邀请10人

    //连续签到 1.0.2->没有存入数据库，没网状态按本地事件来算
    private List<SignLasting> signList;//连续签到数据
    private String signDays;//连续签到的日期

    //粉丝和关注： 2.0.1新增字段
    private String fans;//粉丝
    private String follows;//关注
    private String rewardUrl;//详细的任务奖励规则
    private String goldUrl;//详细的任务奖励规则
    private String scoreUrl;//详细的任务奖励规则
    //2.0.1-新增 签到提示语
    private String signNotice;//签到提示语

    private String isEvaluated;//是否弹评分的庄口

    //204
    private String exchangeUrl;//兑换中心连接

    public String getGameDownloadNum() {
        return gameDownloadNum;
    }

    public void setGameDownloadNum(String gameDownloadNum) {
        this.gameDownloadNum = gameDownloadNum;
    }

    public String getScoreUrl() {
        return scoreUrl;
    }

    public void setScoreUrl(String scoreUrl) {
        this.scoreUrl = scoreUrl;
    }

    public String getGoldUrl() {
        return goldUrl;
    }

    public void setGoldUrl(String goldUrl) {
        this.goldUrl = goldUrl;
    }

    public String getReadNum() {
        return readNum;
    }

    public void setReadNum(String readNum) {
        this.readNum = readNum;
    }

    public String getExchangeUrl() {
        return exchangeUrl;
    }

    public void setExchangeUrl(String exchangeUrl) {
        this.exchangeUrl = exchangeUrl;
    }

    public boolean getIsEvaluated() {//1是弹窗

        return !(TextUtils.isEmpty(isEvaluated) || TextUtils.equals("0", isEvaluated));
    }

    public boolean getIsInvited() {
        if (TextUtils.equals("1", isInvited)) {
            return true;
        }
        return false;
    }

    public void setIsInvited(String isInvited) {
        this.isInvited = isInvited;
    }

    public void setIsEvaluated(String isEvaluated) {
        this.isEvaluated = isEvaluated;
    }

    public String getSignNotice() {
        return signNotice;
    }

    public void setSignNotice(String signNotice) {
        this.signNotice = signNotice;
    }

    public String getRewardUrl() {
        return rewardUrl;
    }

    public void setRewardUrl(String rewardUrl) {
        this.rewardUrl = rewardUrl;
    }

    public String getFans() {
        return TextUtils.isEmpty(fans) ? "0" : fans;
    }

    public void setFans(String fans) {
        this.fans = fans;
    }

    public String getFollows() {
        return TextUtils.isEmpty(follows) ? "0" : follows;
    }

    public void setFollows(String follows) {
        this.follows = follows;
    }

    public String getSignDays() {
        return TextUtils.isEmpty(signDays) ? "0" : signDays;
    }

    public void setSignDays(String signDays) {
        this.signDays = signDays;
    }

    public List<SignLasting> getSignList() {
        return signList;
    }

    public void setSignList(List<SignLasting> signList) {
        this.signList = signList;
    }

    public String getDayPayMax() {
        return dayPayMax == null ? "0" : dayPayMax;
    }

    public void setDayPayMax(String dayPayMax) {
        this.dayPayMax = dayPayMax;
    }

    public String getDayExploitMax() {
        return dayExploitMax == null ? "0" : dayExploitMax;
    }

    public void setDayExploitMax(String dayExploitMax) {
        this.dayExploitMax = dayExploitMax;
    }

    public String getRewardWx() {
        return TextUtils.isEmpty(rewardWx) ? "0" : rewardWx;
    }

    public void setRewardWx(String rewardWx) {
        this.rewardWx = rewardWx;
    }

    public String getRewardMobile() {
        return TextUtils.isEmpty(rewardMobile) ? "0" : rewardMobile;
    }

    public void setRewardMobile(String rewardMobile) {
        this.rewardMobile = rewardMobile;
    }

    public String getRewardSignSeven() {
        return TextUtils.isEmpty(rewardSignSeven) ? "0" : rewardSignSeven;
    }

    public void setRewardSignSeven(String rewardSignSeven) {
        this.rewardSignSeven = rewardSignSeven;
    }

    public String getRewardSignThirty() {
        return TextUtils.isEmpty(rewardSignThirty) ? "0" : rewardSignThirty;
    }

    public void setRewardSignThirty(String rewardSignThirty) {
        this.rewardSignThirty = rewardSignThirty;
    }

    public String getRewardInviteTen() {
        return TextUtils.isEmpty(rewardInviteTen) ? "0" : rewardInviteTen;
    }

    public void setRewardInviteTen(String rewardInviteTen) {
        this.rewardInviteTen = rewardInviteTen;
    }


    //在get方法中处理逻辑时返回的boolean
    private boolean flag = false;//任务是否完成

    public UserTask() {
    }


    public UserTask(String shareNum, String level, String militaryExploit, String militarPay,
                    String mobileBind, String dayPay, String dayExploit, String isLevelUp,
                    String rankName, String nextRankName, String rankIcon, String nextRankIcon,
                    String militaryExploitDiff, String firstLogin, String inviteNum, String wxAttion,
                    String signIn, String commentNum, String militaryDiff, String rewardWx, String rewardMobile,
                    String rewardSignSeven, String rewardSignThirty, String rewardInviteTen) {
        this.shareNum = shareNum;
        this.level = level;
        this.militaryExploit = militaryExploit;
        this.militarPay = militarPay;
        this.mobileBind = mobileBind;
        this.dayPay = dayPay;
        this.dayExploit = dayExploit;
        this.isLevelUp = isLevelUp;
        this.rankName = rankName;
        this.nextRankName = nextRankName;
        this.rankIcon = rankIcon;
        this.nextRankIcon = nextRankIcon;
        this.militaryExploitDiff = militaryExploitDiff;
        this.firstLogin = firstLogin;
        this.inviteNum = inviteNum;
        this.wxAttion = wxAttion;
        this.signIn = signIn;
        this.commentNum = commentNum;
        this.militaryDiff = militaryDiff;
        this.rewardWx = rewardWx;
        this.rewardMobile = rewardMobile;
        this.rewardSignSeven = rewardSignSeven;
        this.rewardSignThirty = rewardSignThirty;
        this.rewardInviteTen = rewardInviteTen;
    }

    /**
     * 获取任务是否完成的方法-评论
     *
     * @return
     */
    public boolean getCommentState() {
        String commentNum = getCommentNum();
        flag = isFlag(commentNum, flag, 5);
        return flag;
    }

    /**
     * 获取任务是否完成的方法-分享
     *
     * @return
     */

    public boolean getShareState() {
        String shareNum = getShareNum();
        flag = isFlag(shareNum, flag, 5);
        return flag;
    }

    /**
     * 获取任务是否完成的方法-分享
     *
     * @return
     */

    public boolean getRedState() {
        String readNum = getReadNum();
        flag = isFlag(readNum, flag, 1);
        return flag;
    }
    /**
     * 获取任务是否完成的方法-分享
     *
     * @return
     */

    public boolean getGameDownloadState() {
        String gameDownloadNum = getGameDownloadNum();
        flag = isFlag(gameDownloadNum, flag, 1);
        return flag;
    }
    /**
     * 获取任务是否完成的方法-邀请
     *
     * @return
     */
    public boolean getInviteState() {
        String inviteNum = getInviteNum();
        flag = isFlag(inviteNum, flag, 1);
        return flag;
    }

    /**
     * 截取字符串"c/t" 判判断任务是否完成
     *
     * @param num
     * @param flag
     * @return
     */
    private boolean isFlag(String num, boolean flag, int defaultValue) {
        if (num == null || TextUtils.isEmpty(num)) {
            flag = false;
        } else {
            String[] split = num.split("/");
            String current = split[0];
            String total = split[1];
            if (StringUtils.toInt(current, 0) >= StringUtils.toInt(total, defaultValue)) {
                flag = true;
            } else {
                flag = false;
            }
        }
        return flag;
    }


    public String getMilitaryDiff() {
        return militaryDiff;
    }

    public void setMilitaryDiff(String militaryDiff) {
        this.militaryDiff = militaryDiff;
    }

    public String getRankIcon() {
        return rankIcon;
    }

    public void setRankIcon(String rankIcon) {
        this.rankIcon = rankIcon;
    }

    public String getNextRankIcon() {
        return nextRankIcon;
    }

    public void setNextRankIcon(String nextRankIcon) {
        this.nextRankIcon = nextRankIcon;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public String getMilitaryExploit() {
        return militaryExploit;
    }

    public void setMilitaryExploit(String militaryExploit) {
        this.militaryExploit = militaryExploit;
    }

    public String getMilitarPay() {
        return militarPay;
    }

    public void setMilitarPay(String militaryPay) {
        this.militarPay = militaryPay;
    }

    public boolean getMobileBind() {//0是false,非0是true
        return !TextUtils.equals("0", mobileBind);
    }

    public void setMobileBind(String mobileBind) {
        this.mobileBind = mobileBind;
    }

    public String getDayPay() {
        return dayPay;
    }

    public void setDayPay(String dayPay) {
        this.dayPay = dayPay;
    }

    public String getDayExploit() {
        return dayExploit;
    }

    public void setDayExploit(String dayExploit) {
        this.dayExploit = dayExploit;
    }

    public boolean getIsLevelUp() {
        //return isLevelUp;
        return !TextUtils.equals("0", isLevelUp);
    }

    public void setIsLevelUp(String isLevelUp) {
        this.isLevelUp = isLevelUp;
    }

    public String getRankName() {
        return rankName;
    }

    public void setRankName(String rankName) {
        this.rankName = rankName;
    }

    public String getNextRankName() {
        return nextRankName;
    }

    public void setNextRankName(String nextRankName) {
        this.nextRankName = nextRankName;
    }

    public String getMilitaryExploitDiff() {
        return militaryExploitDiff;
    }

    public void setMilitaryExploitDiff(String militaryExploitDiff) {
        this.militaryExploitDiff = militaryExploitDiff;
    }


    public boolean getFirstLogin() {
        return !TextUtils.equals("0/1", firstLogin);
    }

    public void setFirstLogin(String firstLogin) {
        this.firstLogin = firstLogin;
    }

    public String getInviteNum() {
        return inviteNum;
    }

    public void setInviteNum(String inviteNum) {
        this.inviteNum = inviteNum;
    }

    public boolean getWxAttion() {
        return !TextUtils.equals("0", wxAttion);
    }

    public void setWxAttion(String wxAttion) {
        this.wxAttion = wxAttion;
    }

    public boolean getSignIn() {
        return !TextUtils.equals("0/1", signIn);
    }

    public void setSignIn(String signIn) {
        this.signIn = signIn;
    }

    public String getCommentNum() {
        return commentNum;
    }

    public void setCommentNum(String commentNum) {
        this.commentNum = commentNum;
    }

    public String getShareNum() {
        return shareNum;
    }

    public void setShareNum(String shareNum) {
        this.shareNum = shareNum;
    }


    public String getPrevRankName() {
        return prevRankName;
    }

    public void setPrevRankName(String prevRankName) {
        this.prevRankName = prevRankName;
    }

    public String getPrevRankIcon() {
        return prevRankIcon;
    }

    public void setPrevRankIcon(String prevRankIcon) {
        this.prevRankIcon = prevRankIcon;
    }
}
